import { Link } from 'react-router-dom'
import { Breadcrumb } from 'antd'
import { useStore } from '@/store'
import { observer } from 'mobx-react'
import './index.scss'

const BreadCrumb = () => {
  const { appStore } = useStore()
  const { currentMenuList } = appStore
  const extraBreadcrumbItems = currentMenuList?.map((item) => (
    <Breadcrumb.Item key={item.path}>{item.title}</Breadcrumb.Item>
  ))

  const breadcrumbItems = [
    <Breadcrumb.Item key="home">
      <Link to="/">首页</Link>
    </Breadcrumb.Item>,
  ].concat(extraBreadcrumbItems)

  return (
    <div className="app-breadcrumb">
      <Breadcrumb style={{ lineHeight: '64px' }}>{breadcrumbItems}</Breadcrumb>
    </div>
  )
}

export default observer(BreadCrumb)
